package com.dianping.cat.consumer.transaction.model.transform;

import com.dianping.cat.consumer.transaction.model.entity.AllDuration;
import com.dianping.cat.consumer.transaction.model.entity.Duration;
import com.dianping.cat.consumer.transaction.model.entity.Graph;
import com.dianping.cat.consumer.transaction.model.entity.Graph2;
import com.dianping.cat.consumer.transaction.model.entity.GraphTrend;
import com.dianping.cat.consumer.transaction.model.entity.Machine;
import com.dianping.cat.consumer.transaction.model.entity.Range;
import com.dianping.cat.consumer.transaction.model.entity.Range2;
import com.dianping.cat.consumer.transaction.model.entity.StatusCode;
import com.dianping.cat.consumer.transaction.model.entity.TransactionName;
import com.dianping.cat.consumer.transaction.model.entity.TransactionReport;
import com.dianping.cat.consumer.transaction.model.entity.TransactionType;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import org.xml.sax.Attributes;























public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public AllDuration buildAllDuration(Attributes attributes) {
/*  49 */     String value = attributes.getValue("value");
/*  50 */     String count = attributes.getValue("count");
/*  51 */     AllDuration allDuration = new AllDuration((value == null) ? 0 : ((Integer)convert(Integer.class, value, Integer.valueOf(0))).intValue());

/*  53 */     if (count != null) {
/*  54 */       allDuration.setCount(((Integer)convert(Integer.class, count, Integer.valueOf(0))).intValue());
    }

/*  57 */     return allDuration;
  }



/*  62 */   public String buildDomain(Attributes attributes) { throw new UnsupportedOperationException(); }



  public Duration buildDuration(Attributes attributes) {
/*  67 */     String value = attributes.getValue("value");
/*  68 */     String count = attributes.getValue("count");
/*  69 */     Duration duration = new Duration((value == null) ? 0 : ((Integer)convert(Integer.class, value, Integer.valueOf(0))).intValue());

/*  71 */     if (count != null) {
/*  72 */       duration.setCount(((Integer)convert(Integer.class, count, Integer.valueOf(0))).intValue());
    }

/*  75 */     return duration;
  }


  public Graph buildGraph(Attributes attributes) {
/*  80 */     String duration = attributes.getValue("duration");
/*  81 */     String sum = attributes.getValue("sum");
/*  82 */     String avg = attributes.getValue("avg");
/*  83 */     String count = attributes.getValue("count");
/*  84 */     String fails = attributes.getValue("fails");
/*  85 */     Graph graph = new Graph((duration == null) ? 0 : ((Integer)convert(Integer.class, duration, Integer.valueOf(0))).intValue());

/*  87 */     if (sum != null) {
/*  88 */       graph.setSum(sum);
    }

/*  91 */     if (avg != null) {
/*  92 */       graph.setAvg(avg);
    }

/*  95 */     if (count != null) {
/*  96 */       graph.setCount(count);
    }

/*  99 */     if (fails != null) {
/* 100 */       graph.setFails(fails);
    }

/* 103 */     return graph;
  }


  public Graph2 buildGraph2(Attributes attributes) {
/* 108 */     String duration = attributes.getValue("duration");
/* 109 */     String sum = attributes.getValue("sum");
/* 110 */     String avg = attributes.getValue("avg");
/* 111 */     String count = attributes.getValue("count");
/* 112 */     String fails = attributes.getValue("fails");
/* 113 */     Graph2 graph2 = new Graph2((duration == null) ? 0 : ((Integer)convert(Integer.class, duration, Integer.valueOf(0))).intValue());

/* 115 */     if (sum != null) {
/* 116 */       graph2.setSum(sum);
    }

/* 119 */     if (avg != null) {
/* 120 */       graph2.setAvg(avg);
    }

/* 123 */     if (count != null) {
/* 124 */       graph2.setCount(count);
    }

/* 127 */     if (fails != null) {
/* 128 */       graph2.setFails(fails);
    }

/* 131 */     return graph2;
  }


  public GraphTrend buildGraphTrend(Attributes attributes) {
/* 136 */     String duration = attributes.getValue("duration");
/* 137 */     String sum = attributes.getValue("sum");
/* 138 */     String avg = attributes.getValue("avg");
/* 139 */     String count = attributes.getValue("count");
/* 140 */     String fails = attributes.getValue("fails");
/* 141 */     GraphTrend graphTrend = new GraphTrend((duration == null) ? 0 : ((Integer)convert(Integer.class, duration, Integer.valueOf(0))).intValue());

/* 143 */     if (sum != null) {
/* 144 */       graphTrend.setSum(sum);
    }

/* 147 */     if (avg != null) {
/* 148 */       graphTrend.setAvg(avg);
    }

/* 151 */     if (count != null) {
/* 152 */       graphTrend.setCount(count);
    }

/* 155 */     if (fails != null) {
/* 156 */       graphTrend.setFails(fails);
    }

/* 159 */     return graphTrend;
  }



/* 164 */   public String buildIp(Attributes attributes) { throw new UnsupportedOperationException(); }



  public Machine buildMachine(Attributes attributes) {
/* 169 */     String ip = attributes.getValue("ip");
/* 170 */     return new Machine(ip);
  }




  public TransactionName buildName(Attributes attributes) {
/* 177 */     String id = attributes.getValue("id");
/* 178 */     String totalCount = attributes.getValue("totalCount");
/* 179 */     String failCount = attributes.getValue("failCount");
/* 180 */     String failPercent = attributes.getValue("failPercent");
/* 181 */     String min = attributes.getValue("min");
/* 182 */     String max = attributes.getValue("max");
/* 183 */     String avg = attributes.getValue("avg");
/* 184 */     String sum = attributes.getValue("sum");
/* 185 */     String sum2 = attributes.getValue("sum2");
/* 186 */     String std = attributes.getValue("std");
/* 187 */     String tps = attributes.getValue("tps");
/* 188 */     String line95Value = attributes.getValue("line95Value");
/* 189 */     String line99Value = attributes.getValue("line99Value");
/* 190 */     String line999Value = attributes.getValue("line999Value");
/* 191 */     String line90Value = attributes.getValue("line90Value");
/* 192 */     String line50Value = attributes.getValue("line50Value");
/* 193 */     String line9999Value = attributes.getValue("line9999Value");
/* 194 */     TransactionName name = new TransactionName(id);

/* 196 */     if (totalCount != null) {
/* 197 */       name.setTotalCount(((Long)convert(Long.class, totalCount, Long.valueOf(0L))).longValue());
    }

/* 200 */     if (failCount != null) {
/* 201 */       name.setFailCount(((Long)convert(Long.class, failCount, Long.valueOf(0L))).longValue());
    }

/* 204 */     if (failPercent != null) {
/* 205 */       name.setFailPercent(toNumber(failPercent, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 208 */     if (min != null) {
/* 209 */       name.setMin(toNumber(min, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 212 */     if (max != null) {
/* 213 */       name.setMax(toNumber(max, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 216 */     if (avg != null) {
/* 217 */       name.setAvg(toNumber(avg, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 220 */     if (sum != null) {
/* 221 */       name.setSum(toNumber(sum, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 224 */     if (sum2 != null) {
/* 225 */       name.setSum2(toNumber(sum2, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 228 */     if (std != null) {
/* 229 */       name.setStd(toNumber(std, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 232 */     if (tps != null) {
/* 233 */       name.setTps(toNumber(tps, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 236 */     if (line95Value != null) {
/* 237 */       name.setLine95Value(toNumber(line95Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 240 */     if (line99Value != null) {
/* 241 */       name.setLine99Value(toNumber(line99Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 244 */     if (line999Value != null) {
/* 245 */       name.setLine999Value(toNumber(line999Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 248 */     if (line90Value != null) {
/* 249 */       name.setLine90Value(toNumber(line90Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 252 */     if (line50Value != null) {
/* 253 */       name.setLine50Value(toNumber(line50Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 256 */     if (line9999Value != null) {
/* 257 */       name.setLine9999Value(toNumber(line9999Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 260 */     return name;
  }


  public Range buildRange(Attributes attributes) {
/* 265 */     String value = attributes.getValue("value");
/* 266 */     String count = attributes.getValue("count");
/* 267 */     String sum = attributes.getValue("sum");
/* 268 */     String avg = attributes.getValue("avg");
/* 269 */     String fails = attributes.getValue("fails");
/* 270 */     String min = attributes.getValue("min");
/* 271 */     String max = attributes.getValue("max");
/* 272 */     String line95Value = attributes.getValue("line95Value");
/* 273 */     String line99Value = attributes.getValue("line99Value");
/* 274 */     String line999Value = attributes.getValue("line999Value");
/* 275 */     String line90Value = attributes.getValue("line90Value");
/* 276 */     String line50Value = attributes.getValue("line50Value");
/* 277 */     String line9999Value = attributes.getValue("line9999Value");
/* 278 */     Range range = new Range((value == null) ? 0 : ((Integer)convert(Integer.class, value, Integer.valueOf(0))).intValue());

/* 280 */     if (count != null) {
/* 281 */       range.setCount(((Integer)convert(Integer.class, count, Integer.valueOf(0))).intValue());
    }

/* 284 */     if (sum != null) {
/* 285 */       range.setSum(((Double)convert(Double.class, sum, Double.valueOf(0.0D))).doubleValue());
    }

/* 288 */     if (avg != null) {
/* 289 */       range.setAvg(toNumber(avg, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 292 */     if (fails != null) {
/* 293 */       range.setFails(((Integer)convert(Integer.class, fails, Integer.valueOf(0))).intValue());
    }

/* 296 */     if (min != null) {
/* 297 */       range.setMin(toNumber(min, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 300 */     if (max != null) {
/* 301 */       range.setMax(toNumber(max, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 304 */     if (line95Value != null) {
/* 305 */       range.setLine95Value(toNumber(line95Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 308 */     if (line99Value != null) {
/* 309 */       range.setLine99Value(toNumber(line99Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 312 */     if (line999Value != null) {
/* 313 */       range.setLine999Value(toNumber(line999Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 316 */     if (line90Value != null) {
/* 317 */       range.setLine90Value(toNumber(line90Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 320 */     if (line50Value != null) {
/* 321 */       range.setLine50Value(toNumber(line50Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 324 */     if (line9999Value != null) {
/* 325 */       range.setLine9999Value(toNumber(line9999Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 328 */     return range;
  }


  public Range2 buildRange2(Attributes attributes) {
/* 333 */     String value = attributes.getValue("value");
/* 334 */     String count = attributes.getValue("count");
/* 335 */     String sum = attributes.getValue("sum");
/* 336 */     String avg = attributes.getValue("avg");
/* 337 */     String fails = attributes.getValue("fails");
/* 338 */     String min = attributes.getValue("min");
/* 339 */     String max = attributes.getValue("max");
/* 340 */     String line95Value = attributes.getValue("line95Value");
/* 341 */     String line99Value = attributes.getValue("line99Value");
/* 342 */     String line999Value = attributes.getValue("line999Value");
/* 343 */     String line90Value = attributes.getValue("line90Value");
/* 344 */     String line50Value = attributes.getValue("line50Value");
/* 345 */     String line9999Value = attributes.getValue("line9999Value");
/* 346 */     Range2 range2 = new Range2((value == null) ? 0 : ((Integer)convert(Integer.class, value, Integer.valueOf(0))).intValue());

/* 348 */     if (count != null) {
/* 349 */       range2.setCount(((Integer)convert(Integer.class, count, Integer.valueOf(0))).intValue());
    }

/* 352 */     if (sum != null) {
/* 353 */       range2.setSum(((Double)convert(Double.class, sum, Double.valueOf(0.0D))).doubleValue());
    }

/* 356 */     if (avg != null) {
/* 357 */       range2.setAvg(toNumber(avg, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 360 */     if (fails != null) {
/* 361 */       range2.setFails(((Integer)convert(Integer.class, fails, Integer.valueOf(0))).intValue());
    }

/* 364 */     if (min != null) {
/* 365 */       range2.setMin(toNumber(min, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 368 */     if (max != null) {
/* 369 */       range2.setMax(toNumber(max, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 372 */     if (line95Value != null) {
/* 373 */       range2.setLine95Value(toNumber(line95Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 376 */     if (line99Value != null) {
/* 377 */       range2.setLine99Value(toNumber(line99Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 380 */     if (line999Value != null) {
/* 381 */       range2.setLine999Value(toNumber(line999Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 384 */     if (line90Value != null) {
/* 385 */       range2.setLine90Value(toNumber(line90Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 388 */     if (line50Value != null) {
/* 389 */       range2.setLine50Value(toNumber(line50Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 392 */     if (line9999Value != null) {
/* 393 */       range2.setLine9999Value(toNumber(line9999Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 396 */     return range2;
  }


  public StatusCode buildStatusCode(Attributes attributes) {
/* 401 */     String id = attributes.getValue("id");
/* 402 */     String count = attributes.getValue("count");
/* 403 */     StatusCode statusCode = new StatusCode(id);

/* 405 */     if (count != null) {
/* 406 */       statusCode.setCount(((Long)convert(Long.class, count, Long.valueOf(0L))).longValue());
    }

/* 409 */     return statusCode;
  }


  public TransactionReport buildTransactionReport(Attributes attributes) {
/* 414 */     String domain = attributes.getValue("domain");
/* 415 */     String startTime = attributes.getValue("startTime");
/* 416 */     String endTime = attributes.getValue("endTime");
/* 417 */     TransactionReport transactionReport = new TransactionReport(domain);

/* 419 */     if (startTime != null) {
/* 420 */       transactionReport.setStartTime(toDate(startTime, "yyyy-MM-dd HH:mm:ss", null));
    }

/* 423 */     if (endTime != null) {
/* 424 */       transactionReport.setEndTime(toDate(endTime, "yyyy-MM-dd HH:mm:ss", null));
    }

/* 427 */     return transactionReport;
  }


  public TransactionType buildType(Attributes attributes) {
/* 432 */     String id = attributes.getValue("id");
/* 433 */     String totalCount = attributes.getValue("totalCount");
/* 434 */     String failCount = attributes.getValue("failCount");
/* 435 */     String failPercent = attributes.getValue("failPercent");
/* 436 */     String min = attributes.getValue("min");
/* 437 */     String max = attributes.getValue("max");
/* 438 */     String avg = attributes.getValue("avg");
/* 439 */     String sum = attributes.getValue("sum");
/* 440 */     String sum2 = attributes.getValue("sum2");
/* 441 */     String std = attributes.getValue("std");
/* 442 */     String tps = attributes.getValue("tps");
/* 443 */     String line95Value = attributes.getValue("line95Value");
/* 444 */     String line99Value = attributes.getValue("line99Value");
/* 445 */     String line999Value = attributes.getValue("line999Value");
/* 446 */     String line90Value = attributes.getValue("line90Value");
/* 447 */     String line50Value = attributes.getValue("line50Value");
/* 448 */     String line9999Value = attributes.getValue("line9999Value");
/* 449 */     TransactionType type = new TransactionType(id);

/* 451 */     if (totalCount != null) {
/* 452 */       type.setTotalCount(((Long)convert(Long.class, totalCount, Long.valueOf(0L))).longValue());
    }

/* 455 */     if (failCount != null) {
/* 456 */       type.setFailCount(((Long)convert(Long.class, failCount, Long.valueOf(0L))).longValue());
    }

/* 459 */     if (failPercent != null) {
/* 460 */       type.setFailPercent(toNumber(failPercent, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 463 */     if (min != null) {
/* 464 */       type.setMin(toNumber(min, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 467 */     if (max != null) {
/* 468 */       type.setMax(toNumber(max, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 471 */     if (avg != null) {
/* 472 */       type.setAvg(toNumber(avg, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 475 */     if (sum != null) {
/* 476 */       type.setSum(toNumber(sum, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 479 */     if (sum2 != null) {
/* 480 */       type.setSum2(toNumber(sum2, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 483 */     if (std != null) {
/* 484 */       type.setStd(toNumber(std, "0.0", Integer.valueOf(0)).doubleValue());
    }

/* 487 */     if (tps != null) {
/* 488 */       type.setTps(toNumber(tps, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 491 */     if (line95Value != null) {
/* 492 */       type.setLine95Value(toNumber(line95Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 495 */     if (line99Value != null) {
/* 496 */       type.setLine99Value(toNumber(line99Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 499 */     if (line999Value != null) {
/* 500 */       type.setLine999Value(toNumber(line999Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 503 */     if (line90Value != null) {
/* 504 */       type.setLine90Value(toNumber(line90Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 507 */     if (line50Value != null) {
/* 508 */       type.setLine50Value(toNumber(line50Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 511 */     if (line9999Value != null) {
/* 512 */       type.setLine9999Value(toNumber(line9999Value, "0.00", Integer.valueOf(0)).doubleValue());
    }

/* 515 */     Map<String, String> dynamicAttributes = type.getDynamicAttributes();
/* 516 */     int _length = (attributes == null) ? 0 : attributes.getLength();

/* 518 */     for (int i = 0; i < _length; i++) {
/* 519 */       String _name = attributes.getQName(i);
/* 520 */       String _value = attributes.getValue(i);

/* 522 */       dynamicAttributes.put(_name, _value);
    }

/* 525 */     dynamicAttributes.remove("id");
/* 526 */     dynamicAttributes.remove("totalCount");
/* 527 */     dynamicAttributes.remove("failCount");
/* 528 */     dynamicAttributes.remove("failPercent");
/* 529 */     dynamicAttributes.remove("min");
/* 530 */     dynamicAttributes.remove("max");
/* 531 */     dynamicAttributes.remove("avg");
/* 532 */     dynamicAttributes.remove("sum");
/* 533 */     dynamicAttributes.remove("sum2");
/* 534 */     dynamicAttributes.remove("std");
/* 535 */     dynamicAttributes.remove("tps");
/* 536 */     dynamicAttributes.remove("line95Value");
/* 537 */     dynamicAttributes.remove("line99Value");
/* 538 */     dynamicAttributes.remove("line999Value");
/* 539 */     dynamicAttributes.remove("line90Value");
/* 540 */     dynamicAttributes.remove("line50Value");
/* 541 */     dynamicAttributes.remove("line9999Value");

/* 543 */     return type;
  }


  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 548 */     if (value == null || value.length() == 0) {
/* 549 */       return defaultValue;
    }

/* 552 */     if (type == Boolean.class || type == boolean.class)
/* 553 */       return (T)Boolean.valueOf(value); 
/* 554 */     if (type == Integer.class || type == int.class)
/* 555 */       return (T)Integer.valueOf(value); 
/* 556 */     if (type == Long.class || type == long.class)
/* 557 */       return (T)Long.valueOf(value); 
/* 558 */     if (type == Short.class || type == short.class)
/* 559 */       return (T)Short.valueOf(value); 
/* 560 */     if (type == Float.class || type == float.class)
/* 561 */       return (T)Float.valueOf(value); 
/* 562 */     if (type == Double.class || type == double.class)
/* 563 */       return (T)Double.valueOf(value); 
/* 564 */     if (type == Byte.class || type == byte.class)
/* 565 */       return (T)Byte.valueOf(value); 
/* 566 */     if (type == Character.class || type == char.class) {
/* 567 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 569 */     return (T)value;
  }


  protected Date toDate(String str, String format, Date defaultValue) {
/* 574 */     if (str == null || str.length() == 0) {
/* 575 */       return defaultValue;
    }

    try {
/* 579 */       return (new SimpleDateFormat(format)).parse(str);
/* 580 */     } catch (ParseException e) {
/* 581 */       throw new RuntimeException(String.format("Unable to parse date(%s) in format(%s)!", new Object[] { str, format }), e);
    }
  }

  protected Number toNumber(String str, String format, Number defaultValue) {
/* 586 */     if (str == null || str.length() == 0) {
/* 587 */       return defaultValue;
    }

    try {
/* 591 */       return (new DecimalFormat(format)).parse(str);
/* 592 */     } catch (ParseException e) {
/* 593 */       throw new RuntimeException(String.format("Unable to parse number(%s) in format(%s)!", new Object[] { str, format }), e);
    }
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-consumer-3.0.0.jar!/com/dianping/cat/consumer/transaction/model/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */